﻿@model DTcms.Model.BaseModel
@{
    ViewBag.Title = "取回密码-" + Model.site.seo_title;
    string action = Model.info["action"].ToString();
    string username = Model.info["username"].ToString();
    string code = Model.info["code"].ToString();
}
@section HeaderContent{
    <link href="/template/pc/main/default/skin/dragcode.css" rel="stylesheet" />
}
<!--当前位置-->
<div class="section">
    <div class="location">
        <span>当前位置：</span>
        <a href="@Html.linkurl("index")">首页</a> &gt;
        <a href="javascript:;">取回密码</a>
    </div>
</div>
<!--/当前位置-->
<!--导航推荐-->
<div class="section">
    <div class="wrapper">
        <div class="bg-wrap">
            <div class="nav-tit">
                <a class="selected" href="javascript:;">取回密码</a>
                <i>|</i>
                <a href="@Html.linkurl("login")">账户登录</a>
            </div>

            @if (action == "")
            {
                <!--取回密码-->
                <form id="pwdForm" name="pwdForm" url="/api/submit_ajax/user_getpassword" class="layui-form">
                    <input name="site_id" type="hidden" value="@Model.site.id" />
                    <div class="form-box full">
                        <dl class="form-group">
                            <dt>激&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;活：</dt>
                            <dd>
                                <input type="hidden" name="imgcodeid" id="imgcodeid" />
                                <div class="authcode2017 clearfix">
                                    <ul class="authcode_btn" id="authcode_btn">
                                        <li data-val="0">0</li>
                                        <li data-val="1">1</li>
                                        <li data-val="2">2</li>
                                        <li data-val="3">3</li>
                                        <li data-val="4">4</li>
                                        <li data-val="5">5</li>
                                        <li data-val="6">6</li>
                                        <li data-val="7">7</li>
                                        <li data-val="8">8</li>
                                        <li data-val="9">9</li>
                                        <div class="success"><s class="s"></s>激活成功</div>
                                    </ul>
                                    <span class="authcode_txt">请点击图中“<span id="authcode_txt"></span>”以激活</span>
                                    <input name="codeindex" id="codeindex" type="hidden" datatype="code" nullmsg="请点击对应字符激活后提交！" sucmsg=" " />
                                    <span class="Validform_checktip"></span>
                                </div>
                            </dd>
                        </dl>
                        <dl class="form-group">
                            <dt>邮箱/手机：</dt>
                            <dd>
                                <input id="chrname" name="chrname" type="text" class="input" datatype="*3-50" sucmsg=" " placeholder="请输入您预留的邮箱地址/手机号码" />
                            </dd>
                        </dl>
                        <dl class="form-group">
                            <dt>验证码：</dt>
                            <dd>
                                <input id="code" name="code" type="text" class="input code" datatype="s3-50" nullmsg="请输入邮箱/手机收到验证码" sucmsg=" " placeholder="请输入验证码" />
                                <span class="d state_1" id="requestYZM_node">
                                    <a href="javascript:void(0);" onclick="return getCodes(this);" id="buttons" class="btn_1">获取验证码</a>
                                    <a href="#" id="daojishiNode" class="btn_2"><span id="daojishi">@(Model.uconfig.regsmsexpired*60)秒</span>后重新发送</a>
                                </span>
                            </dd>
                        </dl>
                        <dl class="form-group">
                            <dt>新密码：</dt>
                            <dd>
                                <input id="txtPassword" name="txtPassword" type="text" class="input" datatype="*6-20" nullmsg="请输入登录密码" errormsg="密码范围在6-20位之间" sucmsg=" " placeholder="密码长度6~16，字母区分大小写" />
                            </dd>
                        </dl>
                        <dl class="form-group">
                            <dt>确认密码：</dt>
                            <dd>
                                <input id="txtPassword1" name="txtPassword1" type="text" class="input" placeholder="重新输入一次密码" datatype="*" recheck="txtPassword" nullmsg="请再输入一次密码" errormsg="两次输入的密码不一致" sucmsg=" " />
                            </dd>
                        </dl>
                        <dl class="form-group">
                            <dd>
                                <input id="btnSubmit" name="btnSubmit" type="submit" value="确认提交" class="submit" />
                            </dd>
                        </dl>
                    </div>
                </form>
                <!--取回密码-->
            }
            else if (action == "error")
            {
                <!--错误界面-->
                <div class="msg-tips">
                    <div class="icon error">
                        <i class="iconfont icon-error"></i>
                    </div>
                    <div class="info">
                        <strong>出错了，该用户不存在或验证已过期！</strong>
                        <p>无法验证你的账户，不知神马原因，可能是你的用户名不存在或者验证码已经过期！</p>
                        <p>不过别担心，如果您还记得你的会员名称的话，点击这里<a href="@Html.linkurl("login")">进入会员中心</a>吧。</p>
                    </div>
                </div>
                <!--/错误界面-->
            }
        </div>
    </div>
</div>
@section Scripts{
    <script type="text/javascript" src="/template/pc/main/default/js/dragcode2.js"></script>
    <script type="text/javascript">
        var timei = @(Model.uconfig.regsmsexpired*60);
        function send(){
         timei--;
         if(timei==-1){
	        timei = @(Model.uconfig.regsmsexpired*60);
            $('#buttons').css('display','block');
	        $('#daojishiNode').hide();
	        return null;
         }
          $("#daojishi").html(timei + "秒") ;
          setTimeout("send();",1000);
        }

        layui.use(['validform', 'form', 'jqueryform'], function () {
            $('#imgcodeid').iAuthcode();
            @if (action == "") {
                @:$("#pwdForm").initValidform('#btnSubmit', 1);
            }
            else {
                @:$("#pwdForm").initValidform('#btnSubmit', 1,'#turl');
            }
        });
        function getCodes(o){
	        var chrname = $("#chrname");
	        if ($('#codeindex').val() === '') {
                layer.msg('请先点击对应字符激活！', {icon: 2});
			    return false;
		    }
            if (chrname.val() === "") {
                    layer.msg('请输入您账户的邮箱地址/手机号码！', {icon: 2});
		            chrname.focus();
		            return false;
	            }
	            $.ajax({
		            url: "/api/submit_ajax/sendFind",
		            type: "POST",
		            timeout: 60000,
		            data: {chrname:chrname.val(),codeindex:$("#codeindex").val(),imgcodeid:$("#imgcodeid").val()},
		            dataType: "json",
		            success: function (data, type) {
                        if(data.islogin==1){
			                $('#buttons').hide();
			                $('#daojishiNode').css('display','block');
                            send();
                            layer.msg(data.msg, {icon: 1});
		                }else{
                            getCode();
                            layer.msg(data.error, {icon: 2});
		                }
		            },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        layer.msg("状态：" + textStatus + "；出错提示：" + errorThrown, {icon: 2});
		            }
                });
	            return false;
            }
    </script>
}